// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) definits fieldsfirst ansi space safe 
// Source File Name:   SliderDialog.java

package jones.gui;

import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.PrintStream;
import javax.swing.*;

public class SliderDialog extends JDialog
{

    private JPanel jContentPane = null;
    private JSlider slider = null;
    private JButton okButton = null;
    private JButton cancelButton = null;
    private boolean isCancelled = false;
    private JPanel buttonPanel = null;
    private JPanel sliderPanel = null;
    private int min = 0;
    private int max = 0;

    public SliderDialog(Frame parent, String title, int min, int max)
    {
        super(parent, title);
        jContentPane = null;
        slider = null;
        okButton = null;
        cancelButton = null;
        isCancelled = true;
        buttonPanel = null;
        sliderPanel = null;
        this.min = min;
        this.max = max;
        setModal(true);
        setContentPane(((java.awt.Container) (getJContentPane())));
        pack();
    }

    public JPanel getJContentPane()
    {
        if (jContentPane == null)
        {
            jContentPane = new JPanel();
            jContentPane.setLayout(((java.awt.LayoutManager) (new BorderLayout())));
            jContentPane.add(((java.awt.Component) (getSliderPanel())), "Center");
            jContentPane.add(((java.awt.Component) (getButtonPanel())), "South");
        }
        return jContentPane;
    }

    public JSlider getSlider()
    {
        if (slider == null)
        {
            slider = new JSlider();
            slider.setMinimum(min);
            slider.setMaximum(max);
            slider.setMinorTickSpacing((max - min) / 20);
            slider.setMajorTickSpacing((max - min) / 5);
            slider.setPaintTicks(true);
            slider.setPaintLabels(true);
            slider.setOrientation(0);
            slider.setSnapToTicks(true);
        }
        return slider;
    }

    public JButton getOKButton()
    {
        if (okButton == null)
        {
            okButton = new JButton();
            okButton.setText("OK");
            okButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e)
                {
                    isCancelled = false;
                    dispose();
                }

            }
);
        }
        return okButton;
    }

    public JButton getCancelButton()
    {
        if (cancelButton == null)
        {
            cancelButton = new JButton();
            cancelButton.setText("Cancel");
            cancelButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e)
                {
                    isCancelled = true;
                    dispose();
                }

            }
);
        }
        return cancelButton;
    }

    public JPanel getButtonPanel()
    {
        if (buttonPanel == null)
        {
            buttonPanel = new JPanel();
            buttonPanel.add(((java.awt.Component) (getOKButton())));
            buttonPanel.add(((java.awt.Component) (getCancelButton())));
        }
        return buttonPanel;
    }

    public JPanel getSliderPanel()
    {
        if (sliderPanel == null)
        {
            sliderPanel = new JPanel();
            sliderPanel.add(((java.awt.Component) (getSlider())));
        }
        return sliderPanel;
    }

    public boolean isCancelled()
    {
        return isCancelled;
    }

    public int getValue()
    {
        System.out.println("SliderDialog.getValue()=" + getSlider().getValue());
        return getSlider().getValue();
    }

    public void setValue(int value)
    {
        getSlider().setValue(value);
    }

}
